/**
 * Project Name:YCApiServer-Api
 * File Name:UserCenterService.java
 * Package Name:com.yc.music.service.service103
 * Date:2016年5月10日下午1:25:36
 * Copyright (c) 2016 
 *
 */
package com.yc.music.service.service103;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.yc.music.common.context.YcContext;
import com.yc.music.common.util.QiNiuUpload;
import com.yc.music.common.util.RoomUtil;
import com.yc.music.context.YtConstant;
import com.yc.music.mapper.cache.CooperateWorkCacheMapper;
import com.yc.music.mapper.cache.UserCacheMapper;
import com.yc.music.mapper.dao.CooperateWorkMapper;
import com.yc.music.mapper.dao.FocusFansMapper;
import com.yc.music.mapper.dao.InspireMapper;
import com.yc.music.mapper.dao.LyricsMapper;
import com.yc.music.mapper.dao.PushMessageFlowMapper;
import com.yc.music.mapper.dao.UserMapper;
import com.yc.music.mapper.dao.WorkFovMapper;
import com.yc.music.mapper.dao.WorkMapper;
import com.yc.music.model.inspire.Inspire;
import com.yc.music.model.musicFov.UserFovCenter;
import com.yc.music.model.musicLyrics.LyricsCenter;
import com.yc.music.model.musicWork.CooperateMusicWorkUser;
import com.yc.music.model.musicWork.CooperateWorkDetail;
import com.yc.music.model.musicWork.WorkBanner;
import com.yc.music.model.musicWork.WorkCenter;
import com.yc.music.model.musicuser.MusicUserVo;

/**
 * 用户主页，中心 service
 * ClassName: UserCenterService <br/>
 * Function: TODO ADD FUNCTION. <br/>
 * Reason: TODO ADD REASON(可选). <br/>
 * date: 2016年5月10日 下午1:25:36 <br/>
 *
 * @author panguixiang
 * @version 
 */
@Service
public class UserCenterService {

	@Autowired
	private FocusFansMapper focusFansMapper;
	
	@Autowired
	private UserCacheMapper userCacheMapper;
	
	@Autowired
	private LyricsMapper lyricsMapper;
	
	@Autowired
	private WorkFovMapper fovMapper;
	
	@Autowired
	private InspireMapper InspireMapper;
	
	@Autowired
	private UserMapper userMapper;
	
	@Autowired
	private WorkMapper workMapper;
	
	@Autowired
	private PushMessageFlowMapper pushMessageFlowMapper;
	
	@Autowired
	private CooperateWorkMapper cooperateWorkMapper;
	
	@Autowired
	private CooperateWorkCacheMapper cooperateWorkCacheMapper;
	
	
	
	
	
	@Value("${Pic_QiLiu}")
	private String pIC_QiLiu;
	
	@Value("${Audio_QiLiu}")
	private String Audio_QiLiu;
	
	@Value("${audio_buckname}")
	private String audio_buckname;
	
	@Value("${pic_buckname}")
	private String pic_buckname;
	/**
	 * 
	 * otherUserCenterDetail:(他人个人中心). <br/> 
	 *
	 * @author panguixiang
	 * @param otherid
	 * @param uid 可为空
	 * @param type 可为空  （ null,0,1=歌曲，2=歌词，3=收藏）
	 * @param page 可为空 页数
	 * @param result
	 * @return
	 * @throws Exception 
	 * @since JDK 1.7
	 */
	public Map<String,Object> otherUserCenterDetail(Long otherid,Long uid,Integer type,Integer page,
			Map<String,Object> result) throws Exception {
		Map<String,Object> dataMap = new HashMap<String,Object>();
		MusicUserVo user = userCacheMapper.getCacheUservo(otherid);
		if(user==null) {
			result.put(YcContext.CODE, 400);
			result.put(YcContext.MESSAGE, YtConstant.USER_IS_NOT_EXIST);
			result.put(YcContext.DATA, YcContext.EMPTY_STRING);
			return result;
		}
		user.setHeadurl(RoomUtil.jointDomain(user.getHeadurl(),pIC_QiLiu));
		//仅第一页放用户的数据
		if (page==1) {
			dataMap.put("user", user);
		}
		//关注数量
		dataMap.put("gznum", focusFansMapper.getFocusCacheCount(otherid));
		//粉丝数量
		dataMap.put("fansnum", focusFansMapper.getMyFansCacheCount(otherid));
		//歌词数量，只查询公开的部分
		dataMap.put("lyricsnum",lyricsMapper.getCountLyricsByOtherUid(otherid));
		//歌曲数量,只查询公开的部分
		dataMap.put("worknum",workMapper.getCountWorkByOtherUid(otherid));
		//灵感记录数量
		dataMap.put("inspirenum",InspireMapper.getCountInspireByUid(otherid));
		//收藏数量
		dataMap.put("fovnum",fovMapper.getCountFov(otherid));
		
		dataMap.put("isFocus",0);//默认为未关注
		if(uid!=null) {
			int a=focusFansMapper.getFocusStatus(otherid, uid);//是否我关注过他
			int b=focusFansMapper.getFocusStatus(uid, otherid);//是否他关注过我
			if(a>0 && b>0) {
				dataMap.put("isFocus",2);//已互相关注
			} else if(a>0 && b==0){
				dataMap.put("isFocus", 1);//已关注
			}
		}
		int start =0;
		if(page!=null && page>1) {
			start=(page-1)*10;
		}
		if(type==2) {//个人主页歌词列表
			getUserLyrics(otherid,dataMap,start,1);//0-不公开，1-公开
		} else if(type==3) {//个人主页收藏列表
			getUserFovList(otherid,dataMap,start);
		} else {//个人主页歌曲列表
			getUserMusics(otherid,dataMap,start,1);//是否发布，0：不发布，1发布
		}
		result.put(YcContext.CODE, 200);
		result.put(YcContext.MESSAGE, YcContext.EMPTY_STRING);
		result.put(YcContext.DATA, dataMap);
		return result;
	}
	
	
	public Map<String,Object> otherUserCenterDetail21(Long otherid,Long uid,Integer type,Integer page,
			Map<String,Object> result) throws Exception {
		Map<String,Object> dataMap = new HashMap<String,Object>();
		MusicUserVo user = userCacheMapper.getCacheUservo(otherid);
		if(user==null) {
			result.put(YcContext.CODE, 400);
			result.put(YcContext.MESSAGE, YtConstant.USER_IS_NOT_EXIST);
			result.put(YcContext.DATA, YcContext.EMPTY_STRING);
			return result;
		}
		user.setHeadurl(RoomUtil.jointDomain(user.getHeadurl(),pIC_QiLiu));
		user.setBgpic(RoomUtil.jointDomain(user.getBgpic(),pIC_QiLiu));
		//仅第一页放用户的数据
		if (page==1) {
			dataMap.put("user", user);
		}
		//关注数量
		dataMap.put("gznum", focusFansMapper.getFocusCacheCount(otherid));
		//粉丝数量
		dataMap.put("fansnum", focusFansMapper.getMyFansCacheCount(otherid));
		//歌词数量，只查询公开的部分
		dataMap.put("lyricsnum",lyricsMapper.getCountLyricsByOtherUid(otherid));
		//歌曲数量,只查询公开的部分
		dataMap.put("worknum",workMapper.getCountWorkByOtherUid(otherid));
		//灵感记录数量
		dataMap.put("inspirenum",InspireMapper.getCountInspireByUid(otherid));
		//收藏数量
		dataMap.put("fovnum",fovMapper.getCountFov(otherid));
		
		dataMap.put("isFocus",0);//默认为未关注
		if(uid!=null) {
			int a=focusFansMapper.getFocusStatus(otherid, uid);//是否我关注过他
			int b=focusFansMapper.getFocusStatus(uid, otherid);//是否他关注过我
			if(a>0 && b>0) {
				dataMap.put("isFocus",2);//已互相关注
			} else if(a>0 && b==0){
				dataMap.put("isFocus", 1);//已关注
			}
		}
		int start =0;
		if(page!=null && page>1) {
			start=(page-1)*10;
		}
		if(type==2) {//个人主页歌词列表
			getUserLyrics(otherid,dataMap,start,1);//0-不公开，1-公开
		} else if(type==3) {//个人主页收藏列表
			getUserFovList(otherid,dataMap,start);
		} else {//个人主页歌曲列表
			getUserMusics(otherid,dataMap,start,1);//是否发布，0：不发布，1发布
		}
		result.put(YcContext.CODE, 200);
		result.put(YcContext.MESSAGE, YcContext.EMPTY_STRING);
		result.put(YcContext.DATA, dataMap);
		return result;
	}
	
	
	public Map<String,Object> otherUserCenterindex22(Long otherid,Long uid,
			Map<String,Object> result) throws Exception {
		Map<String,Object> dataMap = new HashMap<String,Object>();
		MusicUserVo user = userCacheMapper.getCacheUservo(otherid);
		if(user==null) {
			result.put(YcContext.CODE, 400);
			result.put(YcContext.MESSAGE, YtConstant.USER_IS_NOT_EXIST);
			result.put(YcContext.DATA, YcContext.EMPTY_STRING);
			return result;
		}
		user.setHeadurl(RoomUtil.jointDomain(user.getHeadurl(),pIC_QiLiu));
		user.setBgpic(RoomUtil.jointDomain(user.getBgpic(),pIC_QiLiu));
		//用户的数据
		dataMap.put("user", user);
		//关注数量
		dataMap.put("gznum", focusFansMapper.getFocusCacheCount(otherid));
		//粉丝数量
		dataMap.put("fansnum", focusFansMapper.getMyFansCacheCount(otherid));
		//歌词数量，只查询公开的部分
		dataMap.put("lyricsnum",lyricsMapper.getCountLyricsByOtherUid(otherid));
		//歌曲数量,只查询公开的部分
		dataMap.put("worknum",workMapper.getCountWorkByOtherUid(otherid));
		//灵感记录数量
		dataMap.put("inspirenum",InspireMapper.getCountInspireByUid(otherid));
		//收藏数量
		dataMap.put("fovnum",fovMapper.getCountFov(otherid));
		
		dataMap.put("isFocus",0);//默认为未关注
		if(uid!=null) {
			int a=focusFansMapper.getFocusStatus(otherid, uid);//是否我关注过他
			int b=focusFansMapper.getFocusStatus(uid, otherid);//是否他关注过我
			if(a>0 && b>0) {
				dataMap.put("isFocus",2);//已互相关注
			} else if(a>0 && b==0){
				dataMap.put("isFocus", 1);//已关注
			}
		}
		result.put(YcContext.CODE, 200);
		result.put(YcContext.MESSAGE, YcContext.EMPTY_STRING);
		result.put(YcContext.DATA, dataMap);
		return result;
	}
	
	
	public Map<String,Object> otherUserCenterindex23(Long otherid,Long uid,
			Map<String,Object> result) throws Exception {
		Map<String,Object> dataMap = new HashMap<String,Object>();
		MusicUserVo user = userCacheMapper.getCacheUservo(otherid);
		if(user==null) {
			result.put(YcContext.CODE, 400);
			result.put(YcContext.MESSAGE, YtConstant.USER_IS_NOT_EXIST);
			result.put(YcContext.DATA, YcContext.EMPTY_STRING);
			return result;
		}
		user.setHeadurl(RoomUtil.jointDomain(user.getHeadurl(),pIC_QiLiu));
		user.setBgpic(RoomUtil.jointDomain(user.getBgpic(),pIC_QiLiu));
		//用户的数据
		dataMap.put("user", user);
		//关注数量
		dataMap.put("gznum", focusFansMapper.getFocusCacheCount(otherid));
		//粉丝数量
		dataMap.put("fansnum", focusFansMapper.getMyFansCacheCount(otherid));
		//歌词数量，只查询公开的部分
		dataMap.put("lyricsnum",lyricsMapper.getCountLyricsByOtherUid(otherid));
		//歌曲数量,只查询公开的部分
		dataMap.put("worknum",workMapper.getCountWorkByOtherUid(otherid));
		//灵感记录数量
		dataMap.put("inspirenum",InspireMapper.getCountInspireByUid(otherid));
		//收藏数量
		dataMap.put("fovnum",fovMapper.getCountFov(otherid));
		//合作作品数量
		dataMap.put("cooperatenum",cooperateWorkMapper.getCountCooperateWorkCountByUId(otherid));
		
		dataMap.put("isFocus",0);//默认为未关注
		if(uid!=null) {
			int a=focusFansMapper.getFocusStatus(otherid, uid);//是否我关注过他
			int b=focusFansMapper.getFocusStatus(uid, otherid);//是否他关注过我
			if(a>0 && b>0) {
				dataMap.put("isFocus",2);//已互相关注
			} else if(a>0 && b==0){
				dataMap.put("isFocus", 1);//已关注
			}
		}
		result.put(YcContext.CODE, 200);
		result.put(YcContext.MESSAGE, YcContext.EMPTY_STRING);
		result.put(YcContext.DATA, dataMap);
		return result;
	}
	
	
	public Map<String,Object> otherUserCenterListDetail22(Long otherid,Long uid,Integer type,Integer page,
			Map<String,Object> result) throws Exception {
		Map<String,Object> dataMap = new HashMap<String,Object>();
		int start =0;
		if(page!=null && page>1) {
			start=(page-1)*10;
		}
		if(type==2) {//个人主页歌词列表
			List<LyricsCenter> list =getUserLyrics22(otherid,dataMap,start,1);//0-不公开，1-公开
			result.put(YcContext.DATA, list);
		} else if(type==3) {//个人主页收藏列表
			List<UserFovCenter> list=getUserFovList22(otherid,dataMap,start);
			result.put(YcContext.DATA, list);
		} else {//个人主页歌曲列表
			List<WorkCenter> list=getUserMusics22(otherid,dataMap,start,1);//是否发布，0：不发布，1发布
			result.put(YcContext.DATA, list);
		}
		result.put(YcContext.CODE, 200);
		result.put(YcContext.MESSAGE, YcContext.EMPTY_STRING);
		
		return result;
	}
	
	
	public Map<String,Object> otherUserCenterListDetail23(Long otherid,Long uid,Integer type,Integer page,
			Map<String,Object> result) throws Exception {
		Map<String,Object> dataMap = new HashMap<String,Object>();
		int start =0;
		if(page!=null && page>1) {
			start=(page-1)*10;
		}
		if(type==2) {//个人主页歌词列表
			List<LyricsCenter> list =getUserLyrics22(otherid,dataMap,start,1);//0-不公开，1-公开
			result.put(YcContext.DATA, list);
		} else if(type==3) {//个人主页收藏列表
			List<UserFovCenter> list=getUserFovList22(otherid,dataMap,start);
			result.put(YcContext.DATA, list);
		} else if(type==5) {//合作作品
			List<CooperateMusicWorkUser> list=getUserCooperateWork23(otherid,dataMap,start);
			result.put(YcContext.DATA, list);
		}else {//个人主页歌曲列表
			List<WorkCenter> list=getUserMusics22(otherid,dataMap,start,1);//是否发布，0：不发布，1发布
			result.put(YcContext.DATA, list);
		}
		result.put(YcContext.CODE, 200);
		result.put(YcContext.MESSAGE, YcContext.EMPTY_STRING);
		
		return result;
	}
	
	
	
	/**
	 * 
	 * userCenterDetail:(用户个人中心). <br/> 
	 *
	 * @author panguixiang
	 * @param uid 必填
	 * @param type 可为空  （ null,0,1=歌曲，2=歌词，3=收藏,4=灵感记录）
	 * @param page 可为空 页数
	 * @param result
	 * @return
	 * @throws Exception 
	 * @since JDK 1.7
	 */
	public Map<String,Object> userCenterDetail(Long uid,Integer type,Integer page,
			Map<String,Object> result) throws Exception {
		Map<String,Object> dataMap = new HashMap<String,Object>();
		MusicUserVo user = userMapper.getUservo(uid);
		if(user==null) {
			result.put(YcContext.CODE, 400);
			result.put(YcContext.MESSAGE, YtConstant.USER_IS_NOT_EXIST);
			result.put(YcContext.DATA, YcContext.EMPTY_STRING);
			return result;
		}
		user.setHeadurl(RoomUtil.jointDomain(user.getHeadurl(),pIC_QiLiu));
		//第一页的时候放用户个人信息
		if (page==1) {
			dataMap.put("user", user);
		}
		//关注数量
		dataMap.put("gznum", focusFansMapper.getFocusCacheCount(uid));
		//粉丝数量
		dataMap.put("fansnum", focusFansMapper.getMyFansCacheCount(uid));
		//歌词数量
		dataMap.put("lyricsnum",lyricsMapper.getCountLyricsByUid(uid));
		//歌曲数量
		dataMap.put("worknum",workMapper.getCountWorkByUid(uid));
		//灵感记录数量
		dataMap.put("inspirenum",InspireMapper.getCountInspireByUid(uid));
		//收藏数量
		dataMap.put("fovnum",fovMapper.getCountFov(uid));
		int start =0;
		if(page!=null && page>1) {
			start=(page-1)*10;
		}
		if(type==2) {//个人主页歌词列表
			getmyLyrics(uid,dataMap,start);
		} else if(type==3) {//个人主页收藏列表
			getUserFovList(uid,dataMap,start);
		} else if(type==4) {//灵感记录
			getUserInspire(uid,dataMap,start);
		} else {//个人主页歌曲列表
			getUserMusics(uid,dataMap,start,null);
		}
		result.put(YcContext.CODE, 200);
		result.put(YcContext.MESSAGE, YcContext.EMPTY_STRING);
		result.put(YcContext.DATA, dataMap);
		return result;
	}
	
	public Map<String,Object> userCenterDetail21(Long uid,Integer type,Integer page,
			Map<String,Object> result) throws Exception {
		Map<String,Object> dataMap = new HashMap<String,Object>();
		MusicUserVo user = userMapper.getUservo(uid);
		if(user==null) {
			result.put(YcContext.CODE, 400);
			result.put(YcContext.MESSAGE, YtConstant.USER_IS_NOT_EXIST);
			result.put(YcContext.DATA, YcContext.EMPTY_STRING);
			return result;
		}
		user.setBgpic(RoomUtil.jointDomain(user.getBgpic(),pIC_QiLiu));
		user.setHeadurl(RoomUtil.jointDomain(user.getHeadurl(),pIC_QiLiu));
		//第一页的时候放用户个人信息
		if (page==1) {
			dataMap.put("user", user);
		}
		//关注数量
		dataMap.put("gznum", focusFansMapper.getFocusCacheCount(uid));
		//粉丝数量
		dataMap.put("fansnum", focusFansMapper.getMyFansCacheCount(uid));
		//歌词数量
		dataMap.put("lyricsnum",lyricsMapper.getCountLyricsByUid(uid));
		//歌曲数量
		dataMap.put("worknum",workMapper.getCountWorkByUid(uid));
		//灵感记录数量
		dataMap.put("inspirenum",InspireMapper.getCountInspireByUid(uid));
		//收藏数量
		dataMap.put("fovnum",fovMapper.getCountFov(uid));
		int start =0;
		if(page!=null && page>1) {
			start=(page-1)*10;
		}
		if(type==2) {//个人主页歌词列表
			getmyLyrics(uid,dataMap,start);
		} else if(type==3) {//个人主页收藏列表
			getUserFovList(uid,dataMap,start);
		} else if(type==4) {//灵感记录
			getUserInspire(uid,dataMap,start);
		} else {//个人主页歌曲列表
			getUserMusics21(uid,dataMap,start,null);
		}
		result.put(YcContext.CODE, 200);
		result.put(YcContext.MESSAGE, YcContext.EMPTY_STRING);
		result.put(YcContext.DATA, dataMap);
		return result;
	}
	
	public Map<String,Object> userCenterIndex22(Long uid,Map<String,Object> result) throws Exception {
		Map<String,Object> dataMap = new HashMap<String,Object>();
		MusicUserVo user = userMapper.getUservo(uid);
		if(user==null) {
			result.put(YcContext.CODE, 400);
			result.put(YcContext.MESSAGE, YtConstant.USER_IS_NOT_EXIST);
			result.put(YcContext.DATA, YcContext.EMPTY_STRING);
			return result;
		}
		user.setBgpic(RoomUtil.jointDomain(user.getBgpic(),pIC_QiLiu));
		user.setHeadurl(RoomUtil.jointDomain(user.getHeadurl(),pIC_QiLiu));
		//第一页的时候放用户个人信息
		dataMap.put("user", user);
		//关注数量
		dataMap.put("gznum", focusFansMapper.getFocusCacheCount(uid));
		//粉丝数量
		dataMap.put("fansnum", focusFansMapper.getMyFansCacheCount(uid));
		//歌词数量
		dataMap.put("lyricsnum",lyricsMapper.getCountLyricsByUid(uid));
		//歌曲数量
		dataMap.put("worknum",workMapper.getCountWorkByUid(uid));
		//灵感记录数量
		dataMap.put("inspirenum",InspireMapper.getCountInspireByUid(uid));
		//收藏数量
		dataMap.put("fovnum",fovMapper.getCountFov(uid));
		
		//推送的关注数量
		dataMap.put("focusnum",pushMessageFlowMapper.getCountPushMessageByUidAndType(uid, YtConstant.PUSH_TYPE_FOCUS, 0));
		
		result.put(YcContext.CODE, 200);
		result.put(YcContext.MESSAGE, YcContext.EMPTY_STRING);
		result.put(YcContext.DATA, dataMap);
		return result;
	}
	
	public Map<String,Object> userCenterIndex23(Long uid,Map<String,Object> result) throws Exception {
		Map<String,Object> dataMap = new HashMap<String,Object>();
		MusicUserVo user = userMapper.getUservo(uid);
		if(user==null) {
			result.put(YcContext.CODE, 400);
			result.put(YcContext.MESSAGE, YtConstant.USER_IS_NOT_EXIST);
			result.put(YcContext.DATA, YcContext.EMPTY_STRING);
			return result;
		}
		user.setBgpic(RoomUtil.jointDomain(user.getBgpic(),pIC_QiLiu));
		user.setHeadurl(RoomUtil.jointDomain(user.getHeadurl(),pIC_QiLiu));
		//第一页的时候放用户个人信息
		dataMap.put("user", user);
		//关注数量
		dataMap.put("gznum", focusFansMapper.getFocusCacheCount(uid));
		//粉丝数量
		dataMap.put("fansnum", focusFansMapper.getMyFansCacheCount(uid));
		//歌词数量
		dataMap.put("lyricsnum",lyricsMapper.getCountLyricsByUid(uid));
		//歌曲数量
		dataMap.put("worknum",workMapper.getCountWorkByUid(uid));
		//灵感记录数量
		dataMap.put("inspirenum",InspireMapper.getCountInspireByUid(uid));
		//收藏数量
		dataMap.put("fovnum",fovMapper.getCountFov(uid));
		//合作作品数量
		dataMap.put("cooperatenum",cooperateWorkMapper.getCountCooperateWorkCountByUId(uid));
		
		//推送的关注数量
		dataMap.put("focusnum",pushMessageFlowMapper.getCountPushMessageByUidAndType(uid, YtConstant.PUSH_TYPE_FOCUS, 0));
		
		result.put(YcContext.CODE, 200);
		result.put(YcContext.MESSAGE, YcContext.EMPTY_STRING);
		result.put(YcContext.DATA, dataMap);
		return result;
	}
	
	
	public Map<String,Object> userCenterListDetail22(Long uid,Integer type,Integer page,
			Map<String,Object> result) throws Exception {
		Map<String,Object> dataMap = new HashMap<String,Object>();
		int start =0;
		if(page!=null && page>1) {
			start=(page-1)*10;
		}
		if(type==2) {//个人主页歌词列表
			List<LyricsCenter> list=getmyLyrics22(uid,dataMap,start);
			result.put(YcContext.DATA, list);
		} else if(type==3) {//个人主页收藏列表
			List<UserFovCenter> list=getUserFovList22(uid,dataMap,start);
			result.put(YcContext.DATA, list);
		} else if(type==4) {//灵感记录
			List<Inspire> list=getUserInspire22(uid,dataMap,start);
			result.put(YcContext.DATA, list);
		} else {//个人主页歌曲列表
			List<WorkCenter> list =getUserMusics22(uid,dataMap,start,null);
			result.put(YcContext.DATA, list);
		}
		result.put(YcContext.CODE, 200);
		result.put(YcContext.MESSAGE, YcContext.EMPTY_STRING);
		return result;
	}
	
	public Map<String,Object> userCenterListDetail23(Long uid,Integer type,Integer page,
			Map<String,Object> result) throws Exception {
		Map<String,Object> dataMap = new HashMap<String,Object>();
		int start =0;
		if(page!=null && page>1) {
			start=(page-1)*10;
		}
		if(type==2) {//个人主页歌词列表
			List<LyricsCenter> list=getmyLyrics22(uid,dataMap,start);
			result.put(YcContext.DATA, list);
		} else if(type==3) {//个人主页收藏列表
			List<UserFovCenter> list=getUserFovList22(uid,dataMap,start);
			result.put(YcContext.DATA, list);
		} else if(type==4) {//灵感记录
			List<Inspire> list=getUserInspire22(uid,dataMap,start);
			result.put(YcContext.DATA, list);
		}else if(type==5) {//合作作品
			List<CooperateMusicWorkUser> list=getUserCooperateWork23(uid,dataMap,start);
			result.put(YcContext.DATA, list);
		} else {//个人主页歌曲列表
			List<WorkCenter> list =getUserMusics22(uid,dataMap,start,null);
			result.put(YcContext.DATA, list);
		}
		result.put(YcContext.CODE, 200);
		result.put(YcContext.MESSAGE, YcContext.EMPTY_STRING);
		return result;
	}
	
	
	
	public Map<String,Object> fanFocusNum22(Long targetuid,Map<String,Object> result) throws Exception {
		int focusNum=pushMessageFlowMapper.getCountPushMessageByUidAndType(targetuid, YtConstant.PUSH_TYPE_FOCUS, 0);
		
		result.put(YcContext.CODE, 200);
		result.put(YcContext.MESSAGE, YcContext.EMPTY_STRING);
		result.put(YcContext.DATA, focusNum);
		return result;
	
	}
	
	/**
	 * 
	 * getUserMusics:(个人主页歌曲列表). <br/> 
	 *
	 * @author panguixiang
	 * @param uid
	 * @param result
	 * @param start
	 * @since JDK 1.7
	 */
	private void getUserMusics(Long uid, Map<String,Object> result,int start,Integer isother) {
		List<WorkCenter> list = workMapper.workCenterList(uid, start, 10,isother);
		if(list!=null) {
			for(WorkCenter obj:list) {
				obj.setPic(RoomUtil.jointDomain(obj.getPic(),pIC_QiLiu));
			}
		}
		result.put("list",list);
	}
	
	private void getUserMusics21(Long uid, Map<String,Object> result,int start,Integer isother) {
		List<WorkCenter> list = workMapper.workCenterList(uid, start, 10,isother);
		if(list!=null) {
			for(WorkCenter obj:list) {
				obj.setPic(RoomUtil.jointDomain(obj.getPic(),pIC_QiLiu));
				obj.setStatus(obj.getIs_issue());
			}
		}
		result.put("list",list);
	}
	
	private List<WorkCenter> getUserMusics22(Long uid, Map<String,Object> result,int start,Integer isother) {
		List<WorkCenter> list = workMapper.workCenterList(uid, start, 10,isother);
		if(list!=null) {
			for(WorkCenter obj:list) {
				obj.setPic(RoomUtil.jointDomain(obj.getPic(),pIC_QiLiu));
				obj.setStatus(obj.getIs_issue());
			}
		}
		return list;
	}
	
	
	/**
	 * 
	 * getUserLyrics:(个人主页歌词列表). <br/> 
	 *
	 * @author panguixiang
	 * @param uid
	 * @param result
	 * @param start
	 * @since JDK 1.7
	 */
	private void getmyLyrics(Long uid, Map<String,Object> result, int start) {
		List<LyricsCenter> list = lyricsMapper.lyrcisMyList(uid, start, 10);
		if(list!=null) {
			for(LyricsCenter obj:list) {
				obj.setPic(RoomUtil.jointDomain(obj.getPic(),pIC_QiLiu));
			}
		}
		result.put("list", list);
	}
	
	private List<LyricsCenter> getmyLyrics22(Long uid, Map<String,Object> result, int start) {
		List<LyricsCenter> list = lyricsMapper.lyrcisMyList(uid, start, 10);
		if(list!=null) {
			for(LyricsCenter obj:list) {
				obj.setPic(RoomUtil.jointDomain(obj.getPic(),pIC_QiLiu));
			}
		}
		return list;
	}
	
	/**
	 * 
	 * getUserLyrics:(他人主页歌词列表). <br/> 
	 *
	 * @author panguixiang
	 * @param uid
	 * @param result
	 * @param start
	 * @since JDK 1.7
	 */
	private void getUserLyrics(Long uid, Map<String,Object> result, int start,Integer status) {
		List<LyricsCenter> list = lyricsMapper.lyrcisOtherList(uid, start, 10,status);
		if(list!=null) {
			for(LyricsCenter obj:list) {
				obj.setPic(RoomUtil.jointDomain(obj.getPic(),pIC_QiLiu));
			}
		}
		result.put("list", list);
	}
	
	private List<LyricsCenter> getUserLyrics22(Long uid, Map<String,Object> result, int start,Integer status) {
		List<LyricsCenter> list = lyricsMapper.lyrcisOtherList(uid, start, 10,status);
		if(list!=null) {
			for(LyricsCenter obj:list) {
				obj.setPic(RoomUtil.jointDomain(obj.getPic(),pIC_QiLiu));
			}
		}
		return list;
	}
	/**
	 * 
	 * getUserFovList:(用户关联的歌词，歌曲收藏列表). <br/> 
	 *
	 * @author panguixiang
	 * @param uid
	 * @param result
	 * @param start
	 * @since JDK 1.7
	 */
	private void getUserFovList(Long uid,Map<String,Object> result, int start) {
		List<UserFovCenter> list = fovMapper.userFovCenterList(uid,start,10);
		MusicUserVo user=null;
		if(list!=null) {
			for(UserFovCenter obj:list) {
				obj.setPic(RoomUtil.jointDomain(obj.getPic(),pIC_QiLiu));
				user=userCacheMapper.getCacheUservo(obj.getUid());
				if(user!=null){
					obj.setAuthor(user.getNickname());
				}
			}
		}
		result.put("list", list);
	}
	
	private List<UserFovCenter> getUserFovList22(Long uid,Map<String,Object> result, int start) {
		List<UserFovCenter> list = fovMapper.userFovCenterList(uid,start,10);
		MusicUserVo user=null;
		if(list!=null) {
			for(UserFovCenter obj:list) {
				obj.setPic(RoomUtil.jointDomain(obj.getPic(),pIC_QiLiu));
				user=userCacheMapper.getCacheUservo(obj.getUid());
				if(user!=null){
					obj.setAuthor(user.getNickname());
				}
			}
		}
		return list;
	}
	
	/**
	 * 
	 * getUserInspire:(灵感记录). <br/> 
	 *
	 * @author panguixiang
	 * @param uid
	 * @param result
	 * @param start
	 * @since JDK 1.7
	 */
	private void getUserInspire(Long uid, Map<String,Object> result,int start) {
		List<Inspire> list = InspireMapper.inSpireListByUid(uid, start, 10);
		if(list!=null) {
			for(Inspire obj : list) {
				obj.setAudio(RoomUtil.batchDomain(obj.getAudio(),Audio_QiLiu));
				obj.setPics(RoomUtil.batchDomain(obj.getPics(),pIC_QiLiu));
			}
		}
		result.put("list", list);
	}
	
	private List<Inspire> getUserInspire22(Long uid, Map<String,Object> result,int start) {
		List<Inspire> list = InspireMapper.inSpireListByUid(uid, start, 10);
		if(list!=null) {
			for(Inspire obj : list) {
				obj.setAudio(RoomUtil.batchDomain(obj.getAudio(),Audio_QiLiu));
				obj.setPics(RoomUtil.batchDomain(obj.getPics(),pIC_QiLiu));
			}
		}
		return list;
	}
	
	
	private List<CooperateMusicWorkUser> getUserCooperateWork23(Long uid, Map<String,Object> result,int start) {
		List<CooperateMusicWorkUser> list=cooperateWorkMapper.getCooperateWorkByUid(uid,start,10);
		if(list!=null) {
			for(CooperateMusicWorkUser obj : list) {
				obj.setPic(RoomUtil.batchDomain(obj.getPic(),pIC_QiLiu));
			}
		}
		return list;
	}
	/**
	 * 
	 * deleteWork:(删除歌曲，歌词，灵感记录). <br/> 
	 *
	 * @author panguixiang
	 * @param id
	 * @param type
	 * @param result
	 * @return
	 * @throws Exception
	 * @since JDK 1.7
	 */
	public Map<String,Object> deleteWork(Long id,Integer type, Map<String,Object> result) throws Exception {
		if(type==1) {
			WorkBanner work = workMapper.getWorkBannerById(id);
			if(work!=null) {
				workMapper.deleteMuById(id);
				deleteWorkQiNiuFile(work.getPic(),work.getPlayurl(),pic_buckname,audio_buckname);
			}
		}else if(type==2){//歌词
			WorkBanner work = lyricsMapper.getLyrWorkBannerById(id);
			if(work!=null) {
				lyricsMapper.deleteById(id);
				deleteWorkQiNiuFile(work.getPic(),work.getPlayurl(),pic_buckname,audio_buckname);
			}
		}else if(type==3){
			Inspire inspire = InspireMapper.getInspireByid(id);
			if(inspire!=null){
				InspireMapper.deleteInspireByid(id);
				deleteInpsiQiNiuFile(inspire,pic_buckname,audio_buckname);
			}
		}
		result.put(YcContext.CODE, 200);
		result.put(YcContext.MESSAGE, YtConstant.SYS_SUCCSS_MSG);
		result.put(YcContext.DATA, YcContext.EMPTY_STRING);
		return result;
	}
	
	
	
	/**
	 * 
	 * deleteInpsiQiNiuFile:(删除七牛上的文件). <br/> 
	 *
	 * @author panguixiang
	 * @param inspire
	 * @param pIC_QiLiu
	 * @param Audio_QiLiu
	 * @throws Exception
	 * @since JDK 1.7
	 */
	private static void deleteInpsiQiNiuFile(final Inspire inspire,final String pIC_QiLiu,
			final String Audio_QiLiu) throws Exception{
		
		new Thread(){
			public void run(){
				String pics=inspire.getPics();
				if(StringUtils.isNotBlank(pics)) {
					String[] picArr = pics.split(",");
					for(String pic:picArr) {
						if(pic.charAt(0)==YcContext.Slashchar){
							pic=pic.replaceFirst(YcContext.Slash, YcContext.EMPTY_STRING);
						}
						QiNiuUpload.deleteByKey(pic, pIC_QiLiu);
					}
				}
				if(StringUtils.isNotBlank(inspire.getAudio())) {
					String autdio = inspire.getAudio();
					if(autdio.charAt(0)==YcContext.Slashchar){
						autdio=autdio.replaceFirst(YcContext.Slash, YcContext.EMPTY_STRING);
					}
					QiNiuUpload.deleteByKey(autdio, Audio_QiLiu);
				}
			}
		}.start();
	}
	
	
	private static void deleteWorkQiNiuFile(final String pic, final String mp3,final String pIC_QiLiu,
			final String Audio_QiLiu) throws Exception{
		
		new Thread(){
			public void run(){
				if(StringUtils.isNotBlank(pic)) {
					String tmppic=YcContext.EMPTY_STRING;
						if(pic.charAt(0)==YcContext.Slashchar){
							tmppic=pic.replaceFirst(YcContext.Slash, YcContext.EMPTY_STRING);
						} else {
							tmppic=pic;
						}
						QiNiuUpload.deleteByKey(tmppic, pIC_QiLiu);
				}
				if(StringUtils.isNotBlank(mp3)) {
					String tmpmp3=YcContext.EMPTY_STRING;
					if(mp3.charAt(0)==YcContext.Slashchar){
						tmpmp3=mp3.replaceFirst(YcContext.Slash, YcContext.EMPTY_STRING);
					} else {
						tmpmp3=mp3;
					}
					QiNiuUpload.deleteByKey(tmpmp3, Audio_QiLiu);
				}
			}
		}.start();
	}
	
}
